home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Code Samples / untested / tcpip / ifish / fish.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  1.7 KB  |  66 lines  |  [TEXT/ttxt]

  1. -- Filename: 
  2. --     fish.sx
  3.  
  4. -- Other Files Required:
  5. --     This file is loaded by loadme.sx in the animate folder. It requires the MediaImporter
  6. --    class, defined in mediaimp.sx, and the Animation class, defined in animate.sx.
  7.  
  8. -- Purpose:  
  9. --    Define a Fish class, which is animated fish which may be dragged and moved
  10. --    in a space.
  11.  
  12. -- Specialized Classes:  
  13. --     Fish
  14.  
  15. -- Instructions to User: 
  16. --    fish.sx imports the media for a Fish animation, and defines a class Fish, a
  17. --    subclass of Animation, Projectile and Dragger. The init method of Fish sets
  18. --    up the animation using an array of bitmaps. The Fish class also overrides the
  19. --    prepareDrag and drop methods, so that another object (the Fish's authorData)
  20. --    can be informed when the Fish is grabbed and dropped.
  21.  
  22. -- Author:
  23. --     Steve Mayer
  24.  
  25. in module InternetFish
  26.  
  27. global p := spawn theScriptDir #("media")
  28. global mm := new MediaImporter path:p smartExtensions:true
  29. mm.invisibleColor := whiteColor
  30. mm.convertToShapes := false
  31.  
  32. -- Import bitmaps for Fish.
  33. global fishBitmaps := new Array
  34. for i := 1 to 7 do
  35. (
  36.     -- Build filename and import bitmap.
  37.     local fileName := ("fishlft" + (i as String) + ".bmp") as StringConstant
  38.     local bm := importObject mm fileName
  39.     append fishBitmaps bm
  40. )
  41.  
  42. class Fish (Animation, Projectile, Dragger)
  43. instance variables
  44.     authorData
  45. end
  46.  
  47. method init self {class Fish} #rest args #key authorData: ->
  48. (
  49.     apply nextMethod self series:fishBitmaps args
  50.     self.authorData := authorData
  51.     self.velocity := new Point x:-6 y:0
  52.     return self
  53. )
  54.  
  55. -- Override prepareDrag to inform my container.
  56. method prepareDrag self {class Fish} location ->
  57. (
  58.     prepareDrag self.authorData self
  59. )
  60.  
  61. -- Override prepareDrag to inform my container.
  62. method drop self {class Fish} location ->
  63. (
  64.     drop self.authorData self
  65. )
  66.